package com.online_exam.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;


@RestController
public class Test {
    @RequestMapping("/test")
    public String test(Integer id, String name, Integer level, String levelName, HttpServletRequest request, HttpServletResponse response) throws JsonProcessingException {
        response.setStatus(404);
        Map map = new HashMap();
        map.put("code", 401);
        map.put("message", "aa");
        ObjectMapper objectMapper = new ObjectMapper();
        String s = objectMapper.writeValueAsString(map);
        return s;
    }
}
